package com.graduate.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.graduate.model.SysMenu;
import com.graduate.model.Tree;
import com.graduate.service.ISysMenuService;

@Controller
@RequestMapping("/menu")
public class MenuController extends BaseController{

	@Autowired
	private ISysMenuService menuService;
	
	@RequestMapping(value="/getMenuListByMap",method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public List<SysMenu> getMenuListByMap(@RequestParam Map<String, Object> map) {
		List<SysMenu> menuList = menuService.getMenuListByMap(map);
		return menuList;
	}
	
	 /**
     * 通过角色id拿到角色的相应权限生成首页左边的权限树
     *
     * @return
     */
    @RequestMapping(value="/getTreeList", method=RequestMethod.POST)
    @ResponseBody
    public Object getTreeList(@RequestParam(value = "id", defaultValue = "0")String id) 
    {
    	List<Tree> treeList = menuService.getTreeListByMap(id);
    	return treeList;
    }
}
